<?php


namespace XinYaTable\Forms\Controllers;


use XinYaTable\Forms\Services\FormService;

class FormController extends BaseController
{
    public $exceptAllAction = true;
    
    private $_formService;

    public function __construct(FormService $formService)
    {
        $this->_formService = $formService;
    }

    /**
     * @apiDefine form 表单管理
     */
    /**
     * @apiVersion v1.0.0
     * @api        {get} /api/forms/{id} 获取表单详情 GET
     * @apiName    getForm
     * @apiGroup   form
     * @apiParam {Number} id 表单id，参数在url上传值
     * @apiSuccessExample {JSON} 结果描述
     * {
     *      "code": 0,
     *      "msg": "请求成功。",
     *      "data": {
     *          "id": 1,
     *          "title": "城市管理",
     *          "table_name": "branch",
     *          "icon": "",
     *          "fields": [
     *              {
     *                  "id": 1,
     *                  "form_id": 1,
     *                  "title": "城市名称",
     *                  "field_name": "name",
     *                  "field_type": "text",
     *                  "props": {
     *                      "placeholder": "城市名称"
     *                  },
     *                  "validate": [
     *                      {
     *                          "type": "string",
     *                          "message": "城市名称类型错误"
     *                      },
     *                      {
     *                          "required": true,
     *                          "message": "城市名称必填"
     *                      }
     *                  ],
     *                  "style": {
     *                      "span": 8
     *                  },
     *                  "display": 1,//新增编辑是否显示
     *                  "searchable": 1,//是否支持搜索
     *                  "show_column": 1,//是否显示在表格列
     *                  "order": 1,
     *                  "options": []
     *          },
     *        ]
     *      }
     * }
     */
    /**
     * @param string tableName
     *
     * @return mixed
     */
    public function getForm($tableName)
    {
        return $this->_formService->getForm($tableName);
    }

}